Verilog HDLbits:Lemmings4(Moore型有限元状态机)

您所在的位置:网站首页 dig dig digging翻译 Verilog HDLbits:Lemmings4(Moore型有限元状态机)

Verilog HDLbits:Lemmings4(Moore型有限元状态机)

2023-08-28 06:13| 来源: 网络整理| 查看: 265

题目

Although Lemmings can walk, fall, and dig, Lemmings aren’t invulnerable. If a Lemming falls for too long then hits the ground, it can splatter. In particular, if a Lemming falls for more than 20 clock cycles then hits the ground, it will splatter and cease walking, falling, or digging (all 4 outputs become 0), forever (Or until the FSM gets reset). There is no upper limit on how far a Lemming can fall before hitting the ground. Lemmings only splatter when hitting the ground; they do not splatter in mid-air. 在这里插入图片描述 在这里插入图片描述

解题思路

与Lemmings3相比Lemmings4需要多加一个状态以及一个计数器。当left_falll或者right_fall的持续时间超过20个时钟周期时就进入die状态,直到系统复位。

代码如下 module top_module( input clk, input areset, // Freshly brainwashed Lemmings walk left. input bump_left, input bump_right, input ground, input dig, output walk_left, output walk_right, output aaah, output digging ); parameter left = 0; parameter right = 1; parameter left_dig = 2; parameter right_dig = 3; parameter left_fall = 4; parameter right_fall = 5; parameter die = 6; reg[2:0] state, next_state; reg[3:0] out; reg [4:0] cnt; reg flag; //fall状态计数器 always@(posedge clk or posedge areset) begin if(areset) cnt


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3